package com.anos.smsfun.model;

import android.os.Parcel;
import android.os.Parcelable;

import com.anos.smsfun.utility.Utils;

public class MessageItem implements Parcelable {

	private int mId;
	private long mThreadId;
	private String mAddress;
	private String mNameDisplay;
	private String mBody;
	private long mLongDate;
	private int mType;// 1: msg của ngta; 2: msg của mình gửi
	private int mStatus;// -1: da gui; 32: dang gui
	private int mSeen;// 0: chua doc; 1: da doc
	private boolean isSelected;

	public MessageItem() {
	}

	public MessageItem(int id, long thread_id, String address, String nameDisplay,
			String body, long date, int type, int status, int seen) {
		this.mId = id;
		this.mThreadId = thread_id;
		this.mAddress = Utils.converStandardNumber(address);
		this.mNameDisplay = nameDisplay;
		this.mBody = body;
		this.mLongDate = date;
		this.mType = type;
		this.mStatus = status;
		this.setSeen(seen);
		this.setSelected(false);
	}

	public String getAddress() {
		return mAddress;
	}

	public void setAddress(String mAddress) {
		this.mAddress = mAddress;
	}

	public String getBody() {
		return mBody;
	}

	public void setBody(String mBody) {
		this.mBody = mBody;
	}

	public long getLongDate() {
		return mLongDate;
	}

	public void setLongDate(long mDate) {
		this.mLongDate = mDate;
	}

	public int getType() {
		return mType;
	}

	public void setType(int mType) {
		this.mType = mType;
	}

	// //////////////////////////////////////////////
	// * Bắt đầu phần implements Parceable //////////
	// //////////////////////////////////////////////

	/**
	 * Constructor private, tạo một instance từ parcel
	 */
	private MessageItem(Parcel in) {
		mId = in.readInt();
		mThreadId = in.readLong();
		mAddress = in.readString();
		mNameDisplay = in.readString();
		mBody = in.readString();
		mLongDate = in.readLong();
		mType = in.readInt();
		mStatus = in.readInt();
		setSeen(in.readInt());
	}

	public static final Parcelable.Creator<MessageItem> CREATOR = new Parcelable.Creator<MessageItem>() {
		public MessageItem createFromParcel(Parcel in) {
			return new MessageItem(in);
		}

		public MessageItem[] newArray(int size) {
			return new MessageItem[size];
		}
	};

	@Override
	public int describeContents() {
		return hashCode();
	}

	/**
	 * Ghi nội dung object vào parcel
	 */
	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeInt(mId);
		dest.writeLong(mThreadId);
		dest.writeString(mAddress);
		dest.writeString(mNameDisplay);
		dest.writeString(mBody);
		dest.writeLong(mLongDate);
		dest.writeInt(mType);
		dest.writeInt(mStatus);
		dest.writeInt(getSeen());
	}

	public int getId() {
		return mId;
	}

	public void setId(int mId) {
		this.mId = mId;
	}

	public String getNameDisplay() {
		return mNameDisplay;
	}

	public void setNameDisplay(String mNameDisplay) {
		this.mNameDisplay = mNameDisplay;
	}

	public String getFormatDate(String formatString) {
		return Utils.convertLongToDateFormat(mLongDate, formatString);
	}

	public int getStatus() {
		return mStatus;
	}

	public void setStatus(int mStatus) {
		this.mStatus = mStatus;
	}


	public long getThreadId() {
		return mThreadId;
	}

	public void setThreadId(long mThreadId) {
		this.mThreadId = mThreadId;
	}

	public int getSeen() {
		return mSeen;
	}

	public void setSeen(int mSeen) {
		this.mSeen = mSeen;
	}

	public boolean isSelected() {
		return isSelected;
	}

	public void setSelected(boolean isSelected) {
		this.isSelected = isSelected;
	}

}
